﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LLClient.ClientServiceRef;
using System.Runtime.Serialization;

namespace LLClient.SaveAndLoad
{
    [Serializable()]
    public class TurnSerialized : ISerializable
    {
        private int cpt_id;
        private string cpt_name;
        private int target_tile;
        private bool shot;
        private bool surrender;

        #region Properties
        public int Cpt_id
        {
            get { return cpt_id; }
            set { cpt_id = value; }
        }

        public string Cpt_name
        {
            get { return cpt_name; }
            set { cpt_name = value; }
        }

        public int Target_tile
        {
            get { return target_tile; }
            set { target_tile = value; }
        }
        public bool Shot
        {
            get { return shot; }
            set { shot = value; }
        }

        public bool Surrender
        {
            get { return surrender; }
            set { surrender = value; }
        }
        #endregion

        public TurnSerialized()
        {

        }

        public TurnSerialized(Turn t)
        {
            //cpt_id = t.Cpt_id;
            cpt_name = t.Cpt_name;
            target_tile = t.Target_tile;
            shot = t.Shot;
            surrender = t.Surrender;
        }

        #region Serialize
        public TurnSerialized(SerializationInfo info, StreamingContext ctxt)
        {
            //this.cpt_id = (int)info.GetValue("CaptainId", typeof(int));
            this.cpt_name = (string)info.GetValue("CaptainName", typeof(string));
            this.target_tile = (int)info.GetValue("TargetTile", typeof(int));
            this.shot = (bool)info.GetValue("Shot", typeof(bool));
            this.surrender = (bool)info.GetValue("Surrender", typeof(bool));
        }

        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
           // info.AddValue("CaptainId", this.cpt_id);
            info.AddValue("CaptainName", this.cpt_name);
            info.AddValue("TargetTile", this.target_tile);
            info.AddValue("Shot", this.shot);
            info.AddValue("Surrender", this.surrender);
        }
        #endregion
    }
}
